* CREATES DATASET AT THE ISCO OCCUPATION LEVEL WITH JOB CHARACTERISTICS FROM ONET

cd "~/Dropbox/Research/entrepreneurs/draft bipolar/O*NET Data/Final_data"


foreach n in 08 88 {
use isco`n'.dta, clear

drop if s_critical_thinking_lv == .

** Standardize all variables 

qui ds isco`n' isco`n'_title, not
local variables `r(varlist)'
foreach var of local variables {
	qui sum `var'
	replace `var' = (`var' - r(mean))/r(sd)
	
}



** Jobs w/strong management component
egen mgmt_skills = rowmax(	s_mgt_financial_resources_lv	/// Skill: mgmt of financial resources
							s_mgt_material_resources_lv		/// Skill: mgmt of material resources
							s_mgt_personnel_resources_lv	/// Skill: mgmt of personnel resources)
							)

egen management = rowmean ( s_complex_problem_solving_lv	/// Skill: complex problem solving (level)
							s_critical_thinking_lv			/// Skill: critical thinking
							s_judgment_decision_making_lv	/// Skill: judgement and decision-making
							mgmt_skills						/// Max of mgmt skills
							s_monitoring_lv 				/// Skill: Monitoring
							s_negotiation_lv 				/// Skill: Negotiation
							s_persuasion_lv 				/// Skill: Persuasion  
							s_time_mgt_lv 					/// Skill: ime mgmt 
							ct_4c1c2 						/// Content: Responsibility for outcomes and results
							ct_4c3a2a						/// Content: Impact of decision on company results
							ct_4c3a2b						/// Content: Frequency of decision-making
							wa_4a2b1_lv 					/// Work Activity: Making decisions and solving problems (level)
							wa_4a2b4_lv						/// Work Activity: Developing objectives and strategies
							wa_4a4b1_lv						/// Work Activity: Coordinating the work and activities of others
							ws_leadership_im				/// Activity: Leadership
							wa_4a4b4_lv						/// Work Activity: Guiding, directing, and motivating subordinates
)

** Jobs w/high decision/making component

egen decision = rowmean( s_complex_problem_solving_lv 	/// Skill: Complex problem solving
						s_critical_thinking_lv 			/// Skill: Critical thi
						s_troubleshooting_lv 			/// Skill: Troubleshooting
						ct_4c3a1 						/// Content: Consequence of error
						ct_4c3a2b 						/// Content: Frequency of decision making
						ct_4c3b8 						///	Content: importance of unstructured over structured work
						wa_4a2a4_lv 					/// Activity: Analyizing data or info
						wa_4a2b1_lv 					/// Activity: Making decisions and solving problems
						wa_4a2b3_lv						/// Activity: Updating and using relevant knowledge
						)


** Jobs w/strong pressure component
egen pressure = rowmean(	ct_4c3c1 				/// Level of competition
							ct_4c3d1 				/// Content: Time pressure
							ct_4c3b4 				/// Content: Importance of being accurate
							ct_4c3a1 				/// Content: Consequence of error
							ws_stress_tolerance_im	/// Work style: Stress tolerance
							)



** Jobs w/strong artistic component
egen artistic = rowmean(	it_artistic 			/// Interest: Artistic
							wa_4a2b2_lv 			/// Work activity: Thinking creatively
							ws_innovation_im 		/// Work stile: Innovation
							s_critical_thinking_lv 	/// Skill: Critical Thinking
							)


** Jobs w/strong social component (human interaction)
egen social = rowmean(  ws_social_orientation_im 				/// Work style: Social orientation
						wa_4a4b6_lv								/// Work Activity: Providing advice to others 
						wa_4a4b5_lv 							/// Work Activity: Coaching and developing others 
						wa_4a4b4_lv 							/// Work Activity: Guiding, directing subordinates  
						wa_4a4a8_lv 							/// Work Activity: Working directly w/public  
						wa_4a4a7_lv 							/// Work Activity: Resolving conflict and negotiating w/others 
						wa_4a4a6_lv 							/// Work Activity: Selling or influencing others  
						wa_4a4a5_lv 							/// Work Activity: Assisting and caring for others  
						wa_4a4a4_lv 							/// Work Activity: Establishing/maintaining personal relations  
						wa_4a4a3_lv 							/// Work Activity: Communicating w/people outside organization  
						wa_4a4a2_lv 							/// Work Activity: Comunicating w/supervisors, peers, subordinates  
						ct_4c1b1g  								/// Content: Coordinate or lead others 
						ct_4c1b1f  								/// Content: Deal w/external customers 
						ct_4c1b1e  								/// Content: Work w/groups or teams 
						ct_4c1a4  								/// Content: Contact w/others 
						ct_4c1a2l  								/// Content: Face-to-face discussions 
						ct_4c1a2c  								/// Content: Public speaking 
						it_social  								/// Interest: Social 
						s_social_perceptiveness_lv  			/// Skill: Social perceptiveness
						s_persuasion_lv  						/// Skill: Persuasion
						s_negotiation_lv  						/// Skill: Negotiation
						s_instructing_lv  						/// Skill: Instructing
						s_active_listening_lv 					/// Skill: Active listening
						)
						
gen social_interest = 	it_social				


** Unstructured jobs & jobs that require flexibility
egen unstructured = rowmean ( 	it_enterprising 					/// Interest: Enterprise
								ct_4c3b8 							/// Content: Unstructured work
								wa_4a2b2_lv 						/// Work activity: Thinking creatively
								ws_adapt_flex_im 					/// Work style: Adaptability and flexibility
								ws_innovation_im					/// Work style: Innovation
)

gen unstructured_work = ct_4c3b8

** Process all variables
keep isco`n' isco`n'_title management decision pressure artistic social social* unstructured*

* generate dummies for top 20% in each dimension
foreach var in management decision pressure artistic social social_interest unstructured_work {
	_pctile `var', n(100)
	gen D`var' = `var' >= r(r80)
}

* generate vingtiles of each dimension
foreach var in management decision pressure artistic social social_interest unstructured_work {
	xtile V`var' = `var', n(20)
}

sort isco`n'
save isco`n'_small.dta, replace
}
